package com.cskaoyan.abstracts;

/*
        假如我们在开发一个系统时需要对员工类进行设计，
        员工包含3个属性：姓名、工号以及工资。
        经理也是员工，除了含有员工的属性外，另为还有一个奖金属性。
        同时，员工和经理，都具有工作的行为

        请使用继承的思想设计出员工类和经理类。

        要求类中提供必要的方法进行属性访问。

 */
public class Demo4Exercise {

    public static void main(String[] args) {

        // 父类类型的引用
        BaseEmployee employee = null;

        // 测试普通员工类
//        String name = "zs";
//        int workId = 1;
//        double salary = 10000;
//        employee = new Employee(name, workId, salary);
//        System.out.println(employee.getName());
//        System.out.println(employee.getWorkId());
//        System.out.println(employee.getSalary());


        // 测试经理类
        String n = "lisi";
        int id = 2;
        double s = 50000;
        double bonus = 50000;

        employee = new Manger(n, id, s, bonus);
        System.out.println(employee.getName());
        System.out.println(employee.getWorkId());
        System.out.println(employee.getSalary());
    }
}

abstract class BaseEmployee {
    // 姓名
   private String name;

   // 工号
   private int workId;

   // 工资
    private double salary;

    public BaseEmployee(String name, int workId, double salary) {
        this.name = name;
        this.workId = workId;
        this.salary = salary;
    }

    // 工作的行为（无法笼统的回答，因为经理也是员工，经理的工作和员工的工作是不一样的）
    public abstract void work();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getWorkId() {
        return workId;
    }

    public void setWorkId(int workId) {
        this.workId = workId;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }
}

// 普通员工类
class Employee extends BaseEmployee {

    public Employee(String name, int workId, double salary) {
        super(name, workId, salary);
    }

    @Override
    public void work() {
        System.out.println("苦力活");
    }
}

// 经理类
// alt + enter 显示idea推荐解决方案
class Manger extends BaseEmployee {

    private double bonus;

    public Manger(String name, int workId, double salary, double bonus) {
        super(name, workId, salary);
        this.bonus = bonus;
    }



    @Override
    public void work() {
        System.out.println("陪客户吃喝玩乐");
    }

    public double getBonus() {
        return bonus;
    }

    public void setBonus(double bonus) {
        this.bonus = bonus;
    }

    @Override
    public double getSalary() {
        return super.getSalary() + bonus;
    }
}

